# requirement of cmake version
CMAKE_MINIMUM_REQUIRED(VERSION 3.5)

# project name
project(CppfilesOperator)

option(IS_WINDOWS OFF)
option(IS_LINUX OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    message(STATUS "Configuring on/for Windows")
    set(IS_WINDOWS ON)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    message(STATUS "Configuring on/for Linux")
    set(IS_LINUX ON)
endif()

#message(FATAL_ERROR ${IS_WINDOWS})

# 寻找boost依赖
# 将BOOST_ROOT环境变量中的"\"转为"/"，将转换后的值存入CMake变量
file(TO_CMAKE_PATH $ENV{BOOST_ROOT} BOOST_ROOT) 
# 将${BOOST_ROOT}加入CMake的模块查找路径
list(APPEND CMAKE_PREFIX_PATH ${BOOST_ROOT}) 
if (IS_WINDOWS)
    find_package(Boost REQUIRED)

	if (DEFINED BOOST_INCLUDE_DIRS)
	message(INFO ${BOOST_INCLUDE_DIRS})
	else()
	set(BOOST_INCLUDE_DIRS ${BOOST_ROOT})
	message(WARNING ${BOOST_INCLUDE_DIRS}/boost)
	endif()

	if(DEFINED BOOST_LIBRARY_DIRS)
	message(INFO ${BOOST_LIBRARY_DIRS})
	else()
	set(BOOST_LIBRARY_DIRS ${BOOST_ROOT}/lib64-msvc-14.2)
	message(WARNING ${BOOST_LIBRARY_DIRS})
	endif()

	file(GLOB BOOST_LIBRARIES ${BOOST_LIBRARY_DIRS}/*vc142-mt-gd-x64-1_74.lib)
else()
	find_package(Boost REQUIRED)
	
	if (DEFINED BOOST_INCLUDE_DIRS)
	message(INFO ${BOOST_INCLUDE_DIRS})
	else()
	set(BOOST_INCLUDE_DIRS "/usr/include/")
	message(WARNING ${BOOST_INCLUDE_DIRS}/boost)
	endif()

	if(DEFINED BOOST_LIBRARY_DIRS)
	message(INFO ${BOOST_LIBRARY_DIRS})
	else()
	set(BOOST_LIBRARY_DIRS "/usr/lib//x86_64-linux-gnu")
	message(WARNING ${BOOST_LIBRARY_DIRS})
	endif()

	file(GLOB BOOST_LIBRARIES ${BOOST_LIBRARY_DIRS}/libboost*.so*)
endif()

# 添加MYSDK依赖
file(TO_CMAKE_PATH $ENV{MYSDK_ROOT} MYSDK_ROOT) 
list(APPEND CMAKE_PREFIX_PATH ${MYSDK_ROOT}) 
set(MYSDK_INCLUDE_DIRS ${MYSDK_ROOT}/include)
set(MYSDK_LIBRARY_DIRS ${MYSDK_ROOT}/lib)
if (IS_WINDOWS)
	file(GLOB MYSDK_LIBRARIES ${MYSDK_LIBRARY_DIRS}/*.lib)
else()
	file(GLOB MYSDK_LIBRARIES ${MYSDK_LIBRARY_DIRS}/*.so)
endif()
set(SPDLOG_ROOT ${MYSDK_ROOT}/3rdParty/spdlog-1.9.2)

# 多线程文件读取测试
add_subdirectory("multiThreads-fileRead")
# 获取文件行数的测试
add_subdirectory("CountLines")
